<?php
  $username = $_POST['username'];
  $password = $_POST['password'];
  $link = mysqli_connect('localhost', 'root', 'root', 'wyyx');
  $sql = "SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password'";
  $res = mysqli_query($link, $sql);
  $data = mysqli_fetch_all($res, MYSQLI_ASSOC);
  mysqli_close($link);
  if (count($data)) {
    $arr = [
      "message" => "恭喜您,登录成功!",
      "code" => 1,
      "info" => $data
    ];
  } else {
    $arr = [
      "message" => "登录失败,请重新输入您的用户名和密码",
      "code" => 0,
    ];
  }
  echo json_encode($arr);
?>
